@extends('admin.master')

@section('style')
    <link rel="stylesheet" href="{{ url('js/prettyphoto/css/prettyPhoto.css') }}">
@endsection

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render() !!}</div>
@endsection

@section('content')
<div class="section-search mb10">
{!! Form::model($where, ['method'=>'get', 'class'=>'form-inline']) !!}
	<div class="form-group">
		{!! Form::text('word', null, ['class'=>'form-control input-text len', 'placeholder'=>'请输入合同号']) !!}
	</div>
	<button type="submit" class="btn btn-default">查询合同</button>
{!! Form::close() !!}
</div>
<div class="gridSection">
{!! Form::open(['url'=>'admin/contract']) !!}
	<table class="table table-hover table-list">
		<thead>
			<tr>
				<th width="60">序号</th>
				<th>客户名称</th>
				<th>添加时间</th>
				<th>合同号</th>
                <th>合同图片</th>
                <th>发票回执</th>
				<th>发票状态</th>
				<th>发票回执</th>
				<th>发票类型</th>
				<th>备注</th>
				<th class="text-right">操作</th>
			</tr>
		</thead>
		<tbody>
			@if (!$data->isEmpty())
				@foreach ($data as $value)
				<tr>
					<td>{{ $i++ }}</td>
					<td>{!! $value->customer->name or '<span class="text-warning"><i class="fa fa-question-circle" aria-hidden="true"></i> 未绑定客户</span>' !!}</td>
					<td>{{ $value->created_at->format('Y-m-d') }}</td>
					<td><code>{{ $value->contract_no }}</code></td>
					<td class="img-padding">
					@if ($value->contract && is_array($value->contract))
						<ul class="contract-imgs">
							@foreach($value->contract as $contract)
		                    <li>
		                        <a href="{{ url($contract) }}" class="thumbnail" rel="prettyPhoto[contracts-{{ $i }}]">
		                        	<img src="{{ thumbFull($contract, 80) }}">
		                        </a>
		                    </li>
							@endforeach
						</ul>
					@endif
					</td>
					<td class="img-padding">
					@if ($value->invoice_receipt && is_array($value->invoice_receipt))
						<ul class="contract-imgs">
							@foreach($value->invoice_receipt as $receipt)
		                    <li>
		                        <a href="{{ url($receipt) }}" class="thumbnail" rel="prettyPhoto[receipts-{{ $i }}]">
		                        	<img src="{{ thumbFull($receipt, 80) }}">
		                        </a>
		                    </li>
							@endforeach
						</ul>
					@endif
					</td>
					<td>
						@if ($value->invoice_status)
							<span class="text-success">发票已开</span>
						@endif
					</td>
					<td>
						@if ($value->invoice_receipt_status)
							<span class="text-success">发票回执已收</span>
						@endif
					</td>
					<td>{{ config('system.invoice_type')[$value->invoice_type] }}</td>
					<td>{{ $value->remark }}</td>
					<td class="text-right">
						<div class="toolbar">
							<a href="{{ route('admin.contract.edit', $value->id) }}" class="btn-link">修改</a>
							<span class="text-explode ">|</span>
							<a href="javascript:void(0);" data-id="{{ $value->id }}" class="btn-link delete-item">删除</a>
						</div>
					</td>
				</tr>
				@endforeach
			@endif
		</tbody>
	</table>
	@if (!$data->isEmpty())
	<table class="table table-fixed table-footer">
		<tfoot>
			<tr>
				<td colspan="9">
					<div class="pagination-box">
						<div class="pull-right">
							<div class="pagination-info">共有{{ $data->total() }}条， 每页显示：20条</div>
							{!! $data->appends(request()->except('page'))->render() !!}
						</div>
					</div>				
				</td>
			</tr>
		</tfoot>
	</table>
	@else
	<div class="simple-none-data text-center box-border">
		<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
		<span class="text-size-14 inline-block ml5">没有查询到符合条件的记录</span>
	</div>
	@endif
{!! Form::close() !!}
</div>
@endsection

@section('foot')
<script src="{{ url('js/prettyphoto/jquery.prettyPhoto.js') }}"></script>
<script>
$(function() {
	$("a[rel^='prettyPhoto']").prettyPhoto({social_tools: ''});
});
</script>
@endsection